import {BasicColumn, FormSchema} from '/@/components/Table';
import {h} from 'vue';
import {Tag} from 'ant-design-vue';

export const columns: BasicColumn[] = [
  {
    title: '机场名称',
    dataIndex: 'airportName',
    width: 180,
  },
  {
    title: '机场地址',
    dataIndex: 'airportAddress',
    width: 180,
  },
  {
    title: '机场热线',
    dataIndex: 'airportPhone',
    width: 100,
  },
  {
    title: '客户经理电话',
    dataIndex: 'managerPhone',
    width: 100,
  },
  {
    title: '三字码',
    dataIndex: 'threeWord',
    width: 80,
  },
  {
    title: '所属区号',
    dataIndex: 'areaCode',
    width: 80,
  },
  {
    title: '百度code',
    dataIndex: 'cityCode',
    width: 80,
  },
  {
    title: '排序',
    dataIndex: 'airportSort',
    width: 80,
  },
  {
    title: '有无合卡',
    dataIndex: 'isHaveHekaRemark',
    width: 80,
    customRender: ({record}) => {
      const isHaveHekaRemark = record.isHaveHekaRemark;
      const color = isHaveHekaRemark == 1 ? 'green' : 'orange';
      const text = isHaveHekaRemark == 1 ? '有' : '无';
      return h(Tag, {color: color}, () => text);
    },
  },
  {
    title: '有无签名',
    dataIndex: 'isNeedSign',
    width: 80,
    customRender: ({record}) => {
      const isNeedSign = record.isNeedSign;
      const color = isNeedSign == 1 ? 'green' : 'orange';
      const text = isNeedSign == 1 ? '有' : '无';
      return h(Tag, {color: color}, () => text);
    },
  },
  {
    title: '是否同步',
    dataIndex: 'isNeedSetShow',
    width: 80,
    customRender: ({record}) => {
      const isNeedSetShow = record.isNeedSetShow;
      const color = isNeedSetShow == 1 ? 'green' : 'orange';
      const text = isNeedSetShow == 1 ? '有' : '无';
      return h(Tag, {color: color}, () => text);
    },
  },
  {
    title: '设置黑名单',
    dataIndex: 'isNeedSetBlack',
    width: 80,
    customRender: ({record}) => {
      const isNeedSetBlack = record.isNeedSetBlack;
      const color = isNeedSetBlack == 1 ? 'green' : 'orange';
      const text = isNeedSetBlack == 1 ? '需要' : '不需要';
      return h(Tag, {color: color}, () => text);
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'airportName',
    label: '机场名称',
    component: 'Input',
    colProps: {span: 5},
  },
  {
    field: 'threeWord',
    label: '三字码',
    component: 'Input',
    colProps: {span: 5},
  }
];

export const formSchema: FormSchema[] = [
  {
    label: '机场名称',
    field: 'airportName',
    component: 'Input',
    required: true,
  },
  {
    label: '机场电话',
    field: 'airportPhone',
    component: 'Input',
    required: true,
  },
  {
    label: '客户经理电话',
    field: 'managerPhone',
    component: 'Input',
    required: true,
    labelWidth: 100
  },
  {
    label: '百度code',
    field: 'cityCode',
    component: 'Input',
    required: true,
  },
  {
    label: '机场首字母',
    field: 'letter',
    component: 'Input',
    required: true,
  },
  {
    label: '机场3字码',
    field: 'threeWord',
    component: 'Input',
    required: true,
  },
  {
    label: '区域',
    field: 'areaCode',
    component: 'Input',
    required: true,
  },
  {
    label: '排序',
    field: 'airportSort',
    component: 'Input',
    required: true,
  },
  {
    label: '有无合卡',
    field: 'isHaveHekaRemark',
    component: 'Select',
    required: true,
    colProps: {span: 8},
    defaultValue: 0,
    componentProps: {
      options: [
        {label: '无', value: 0},
        {label: '有', value: 1},
      ]
    },
  },
  {
    label: '有无签名',
    field: 'isNeedSign',
    component: 'Select',
    required: true,
    colProps: {span: 8},
    defaultValue: 0,
    componentProps: {
      options: [
        {label: '无', value: 0},
        {label: '有', value: 1},
      ]
    },
  },
  {
    label: '机场地址',
    field: 'airportAddress',
    component: 'Input',
    required: true,
    colProps: {span: 20},
  },
  {
    label: '设置黑名单',
    field: 'isNeedSetBlack',
    component: 'Select',
    required: true,
    colProps: {span: 8},
    defaultValue: 0,
    componentProps: {
      options: [
        {label: '不需要', value: 0},
        {label: '需要', value: 1},
      ]
    },
  }
];
